﻿
@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <title>编辑文档页面</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <script type="text/javascript">
        //获取父页面openWindow的第三个参数的值
        var param = pageofficectrl.WindowParams;
        var paramArr = param.split(",");
        var strKey = paramArr[0];
        var id = paramArr[1];

        function Save() {
            if (strKey != "") SetKeyWord(strKey, false);

            var myObject = {};
            myObject.id = id;
            var params = new URLSearchParams(myObject);
            var saveUrl = "/SaveAndSearch/SaveDoc";
            pageofficectrl.SaveFilePage = `${saveUrl}?${params.toString()}`;
            pageofficectrl.WebSave();

            if (pageofficectrl.CustomSaveResult == "ok")
                alert("保存成功");
            else
                alert(pageofficectrl.CustomSaveResult);
        }

        function SetKeyWord(key, visible) {
            if (key == "null" || "" == key) {
                alert("关键字为空。");
                return;
            }
            let falg = true;
            pageofficectrl.word.HomeKey(6);
            while (falg) {
                if (pageofficectrl.word.FindNextText(key)) {
                    if (visible) {
                        pageofficectrl.word.SetHighlightToSelection(7);
                    } else {
                        pageofficectrl.word.SetHighlightToSelection(0);
                    }
                } else {
                    pageofficectrl.word.HomeKey(6)
                    break;
                }
            }

        }

        function OnPageOfficeCtrlInit() {
            pageofficectrl.AddCustomToolButton("保存", "Save", 1);
        }

    </script>
</head>
<body>
    <form id="form1">
        <input name="button" id="Button1" type="button" onclick="SetKeyWord(strKey,true)" value="高亮显示关键字" />
        <input name="button" id="Button2" type="button" onclick="SetKeyWord(strKey,false)" value="取消关键字显示" />
        <div style="width: auto; height: 900px;">
            @Html.Raw(ViewBag.poCtrl)
        </div>
    </form>
</body>
</html>